package com.egg.basic.service.pay.factory;

import com.egg.basic.entity.pay.PayRecord;
import com.egg.basic.entity.pay.RefundRecord;
import com.egg.basic.enums.pay.PayTypeEnum;
import com.egg.common.core.model.response.ResponseData;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 支付顶层接口
 *
 * @Author: east
 */
public interface IPayFactory {


    Map<String, IPayFactory> container = new ConcurrentHashMap<>();

    static IPayFactory findFactory(PayTypeEnum payType) {
        return findFactory(payType.getCode());
    }

    static IPayFactory findFactory(String payType) {
        return IPayFactory.container.get(payType);
    }

    /**
     * 拉起支付
     *
     * @param pr
     * @return
     */
    ResponseData<String> add(PayRecord pr);

    /**
     * 退款
     *
     * @param refund
     * @return
     */
    ResponseData<String> refund(RefundRecord refund);

    /**
     * 回调
     *
     * @return
     */
    void payNotify();
}
